package util;

import java.util.ArrayList;
import java.util.Collection;

public class Functional {
	public static abstract class Folder<A,B>
	{
		protected B acc;
		public Folder(B acc)
		{
			this.acc = acc;
		}
		public abstract B fold(A a);
		public B getAcc()
		{
			return acc;
		}
	}
	public interface Filter<A>
	{
		public boolean accepts(A a);
	}
	public  static<A> Collection<A> filter(Collection<A> coll,Filter<A> f )
	{
		Collection<A> rv = new ArrayList<A>();
		for(A a : coll)
			if(f.accepts(a))
				rv.add(a);
		return rv;
	}
	
}
